import React, { useState, useEffect } from 'react';
import './index.css';
import { Button, Select, Radio, Input, Checkbox, DatePicker } from 'antd';
import Editor from '../../../Editor';
import { request } from 'umi';

export default function index() {
  const { Search } = Input;
  const [contentData, setContentData] = useState('赵家兴制作'); // 富文本数据
  const [alltaskdataid, setalltaskdataid] = useState(
    JSON.parse(sessionStorage.getItem('taskid')),
  );
  const [alltaskdata, setalltaskdata] = useState({});
  const setDetails = (content) => setContentData(content);
  useEffect(() => {});
  // 数据
  const [list, setList] = useState(
    JSON.parse(sessionStorage.getItem('tasklistji')),
  );
  //登录之后的用户信息
  const [userMessage, setMessage] = useState(
    JSON.parse(sessionStorage.getItem('userMessage')),
  );
  useEffect(() => {
    let url = `/api/task/gettaskdan/${alltaskdataid}`;
    request(url, {
      method: 'get',
    }).then((res) => {
      // console.log(res.data[0]);
      // var newdata = new Date(res.data[0].topdata)
      //   .toLocaleString()
      //   .split('00:00:00');
      // res.topdata = newdata
      // var newdata1 = new Date(res.data[0].enddata)
      //   .toLocaleString()
      //   .split('00:00:00');
      // res.enddata = newdata1
      setalltaskdata(res.data[0]);
    });
  }, []);
  return (
    <div>
      <div>
        <Button className="user_btn">草稿箱</Button>
        <Button className="user_btn">导入</Button>
        <Button className="user_btn">打印</Button>
        <Button className="user_btn">查看日志</Button>
      </div>
      <div className="initiatetaskbody">
        <div className="initiatetaskbodytop">
          <h1>发起任务</h1>
        </div>
      </div>
      <div>
        <table border={1}>
          <tr>
            <td className="title">任务名称：</td>
            <td className="shuru">
              {/* <Input onChange={tasknamedataclick}></Input> */}
              {alltaskdata.taskname}
            </td>
            <td className="title">发起人：</td>
            <td className="shuru">{userMessage.username}</td>
          </tr>
          <tr>
            <td className="title">任务级别：</td>
            <td className="shuru">
              {/* <Radio.Group defaultValue={'重要'} onChange={taskleveldataclick}>
                {list.map((res) => {
                  return <Radio value={res.title}>{res.title}</Radio>;
                })}
              </Radio.Group> */}
              {alltaskdata.tasklevel}
            </td>
            <td className="title">任务状态：</td>
            <td className="shuru">
              {/* <Radio.Group disabled={true} value={'未开始'}>
                <Radio value={'未开始'}>未开始</Radio>
                <Radio value={'进行中'}>进行中</Radio>
                <Radio value={'已完成'}>已完成</Radio>
              </Radio.Group> */}
              {alltaskdata.taskstart}
            </td>
          </tr>
          <tr>
            <td className="title">责任人：</td>
            <td className="shuru">
              {/* <Search style={{ width: 530 }} /> */}
              {alltaskdata.person}
            </td>
            <td className="title">协办人：</td>
            <td className="shuru">
              {/* <Search style={{ width: 530 }} /> */}
              {alltaskdata.xieperson}
            </td>
          </tr>
          <tr>
            <td className="title">开始日期：</td>
            <td className="shuru">
              {new Date(alltaskdata.topdata).toLocaleString().split('00:00:00')}
              {/* <DatePicker style={{ width: 530 }} onChange={topdatadataclick} /> */}
              {/* {alltaskdata.topdata} */}
            </td>
            <td className="title">知会人：</td>
            <td>
              {/* <Search style={{ width: 530 }} /> */}
              {alltaskdata.zhiperson}
            </td>
          </tr>
          <tr>
            <td className="title">结束日期：</td>
            <td className="shuru">
              {new Date(alltaskdata.enddata).toLocaleString().split('00:00:00')}
              {/* <DatePicker style={{ width: 530 }} onChange={enddatadataclick} /> */}
              {/* {alltaskdata} */}
            </td>
            <td className="title"></td>
            <td></td>
          </tr>
          <tr>
            <td className="title" style={{ height: '300px' }}>
              任务说明：
            </td>
            <td colspan={3} style={{ height: '300px' }}>
              {/* <Editor setDetails={setDetails} content={contentData}></Editor> */}
              {alltaskdata.taskexplain}
            </td>
            <td></td>
            <td></td>
          </tr>
        </table>
      </div>
      <div style={{ marginTop: '20px' }}>
        <div className="taskbuttomtop">
          <p style={{ marginLeft: '10px' }}>附件上传</p>
          {/* <Button className="user_btn">批量上传</Button> */}
        </div>
        <table border={1}>
          <tr>
            <td className="title1" style={{ width: '500px' }}>
              文件名称
            </td>
            <td className="title1">文件大小</td>
            <td className="title1">上传人</td>
            <td className="title1">上传时间</td>
            <td className="title1"></td>
            <td className="title1"></td>
            <td className="title1"></td>
            <td className="title1"></td>
            <td className="title1"></td>
          </tr>
          <tr>
            <td className="taskbuttombuttom" colspan={9}></td>
          </tr>
        </table>
      </div>
    </div>
  );
}
